import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    })
  ],
  // server: {
  //   port: 18082,
  //   host: '0.0.0.0',
  //   proxy: {
  //     '/img-tx': {
  //       target: 'http://121.34.242.119', // 'https://tjxt-dev.itheima.net/',
  //       // target: 'http://localhost',
  //       changeOrigin: true
  //       // rewrite: (path) => {
  //       //   return path.replace(/^\/img-tx/, '')
  //       // }
  //     }
  //     // '/mock/3359': {
  //     //   target: 'http://172.17.0.137:8321/mock/3359',
  //     //   changeOrigin: true
  //     // }
  //   }
  // },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
